package com.mymaxis.utils;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;




public class LogWriter {
 
   

    public static  void doLogging(String strReqID, String str1, String methodName, String str2, String logMsg) {
 	   
    	
    
    		SimpleDateFormat dt1 = new SimpleDateFormat("ddMMyyyy");
    		Date date = new Date();
    		System.out.println(dt1.format(date));
    		//File log = new File("C:/Documents and Settings/mebuser/Desktop/mymaxisapp"+dt1.format(date) + ".log");
    		//File log = new File("/app/cfi/v55/log/webservices/receiveWs123"+dt1.format(date) + ".log");
    		File log = new File("/app/tomcat5.5/log/receiveWs_"+dt1.format(date) + ".log");
    		try{
    		    if(!log.exists()){
    		        System.out.println("We had to make a new file.");
    		        log.createNewFile();
    		    }

    		    FileWriter fileWriter = new FileWriter(log, true);
    		    //fh.setFormatter(new SimpleFormatter());
    		    BufferedWriter bufferedWriter = new BufferedWriter(fileWriter);
    		    bufferedWriter.write(date+"(INFO) : REQID :"+ strReqID+","+"OPERATIONTYPE :"+methodName +","+"DATAOUT :"+logMsg);
    		    bufferedWriter.newLine();
    		    bufferedWriter.close();

    		    System.out.println("Done ");
    		} catch(IOException e) {
    		    System.out.println("COULD NOT LOG!!");
    		}
    	  
    	   
    		
    	}
    
} 
